package xuhaijia.lanou3g.autohome.findcar.brand;
//                .-~~~~~~~~~-._       _.-~~~~~~~~~-.
//            __.'              ~.   .~              `.__
//          .'//                  \./                   \\`.
//        .'//            为什么坚持  想一想当初             \\`.
//      .'// .-~"""""""~~~~-._     |     _,-~~~~"""""""~-.  \\`.
//    .'//.-"                 `-.  |  .-'                 "-. \\`.
//  .'//______.============-..   \ | /   ..-============._______\\`.
//.'//____________________________\|/_____________________________\\`.
// 
//                             

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import xuhaijia.lanou3g.autohome.R;
import xuhaijia.lanou3g.autohome.base.NetTool;

/**
 * Created by 7 on 16/8/23.
 */
public class HotBrandAdapter extends RecyclerView.Adapter<HotBrandAdapter.HotBrandViewHolder> {
    Context context;
    HotBrandBean hotBrandBean;

    public HotBrandAdapter(Context context) {
        this.context = context;
    }

    public void setHotBrandBean(HotBrandBean hotBrandBean) {
        this.hotBrandBean = hotBrandBean;
        notifyDataSetChanged();
    }

    @Override
    public HotBrandViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_rv_function, parent, false);
        HotBrandViewHolder hotBrandViewHolder = new HotBrandViewHolder(view);
        return hotBrandViewHolder;
    }

    @Override
    public void onBindViewHolder(HotBrandViewHolder holder, int position) {
        NetTool mNetTool = new NetTool();
        holder.nameTv.setText(hotBrandBean.getResult().getList().get(position).getName());
        holder.nameTv.setTextColor(0xff414348);
        mNetTool.getImage(hotBrandBean.getResult().getList().get(position).getImg() , holder.iconIv);
    }

    @Override
    public int getItemCount() {
        if (hotBrandBean.getResult().getList() == null) {
            return 0;
        }
        return hotBrandBean.getResult().getList().size();
    }

    public class HotBrandViewHolder extends RecyclerView.ViewHolder {
        TextView nameTv;
        ImageView iconIv;

        public HotBrandViewHolder(View itemView) {
            super(itemView);
            nameTv = (TextView) itemView.findViewById(R.id.item_rv_function_tv);
            iconIv = (ImageView) itemView.findViewById(R.id.item_rv_function_iv);
        }
    }
}
